package zua.program.androidstudioprogram01;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class PersonaInformationActivity extends AppCompatActivity {
    TextView username_name,petName_name;
    Button start_exam,information_reset_password,information_back;
    String str = null;

    //保存函数
    @Override
    protected void onSaveInstanceState(@NonNull Bundle outState) {
        super.onSaveInstanceState(outState);
    }

    @SuppressLint({"MissingInflatedId", "SetTextI18n"})
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activite_personalnformation);

        //将定义的值与其在xml中对应的id绑定
        username_name = findViewById(R.id.username_name);
        petName_name = findViewById(R.id.petName_name);
        start_exam = findViewById(R.id.start_exam);
        information_reset_password = findViewById(R.id.information_reset_password);
        information_back = findViewById(R.id.information_back);

        Intent intent_come = getIntent();
        //username_name.setText(getResources().getString(R.string.username_name1));
        str = intent_come.getStringExtra("username");
        username_name.setText(str);

        if (username_name.getText().toString().equals(getResources().getString(R.string.username_name1))) {
            petName_name.setText(getResources().getText(R.string.petName_name1));
        }
        if (username_name.getText().toString().equals(getResources().getString(R.string.username_name2))) {
            petName_name.setText(getResources().getText(R.string.petName_name2));
        }
        if (username_name.getText().toString().equals(getResources().getString(R.string.username_name3))) {
            petName_name.setText(getResources().getText(R.string.petName_name3));
        }
        //setResult(521);

        start_exam.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(PersonaInformationActivity.this, "小可爱加油", Toast.LENGTH_SHORT).show();
                Intent intent1 = new Intent(PersonaInformationActivity.this,QuestionActivity.class);
                intent1.putExtra("username",username_name.getText().toString());
                startActivity(intent1);
            }
        });
        information_reset_password.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(PersonaInformationActivity.this, "要记住自己的新密码哦~~", Toast.LENGTH_SHORT).show();
                String str1 = username_name.getText().toString();
                Intent intent1 = new Intent(PersonaInformationActivity.this,ForgetPasswordActivity.class);
                intent1.putExtra("username",str1);
                startActivity(intent1);
            }
        });
        information_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(PersonaInformationActivity.this, "成功退出，期待与你下次相见", Toast.LENGTH_SHORT).show();
                String str1 = username_name.getText().toString();
                Intent intent3 = new Intent(PersonaInformationActivity.this,MainActivity.class);
                intent3.putExtra("username",str1);
                startActivity(intent3);
            }
        });
    }
}
